Ext.define('AmpleHarvest.objects.harvestrequest.view.window.deactivation.Form', 
{
    extend: 'Ext.form.Panel',
    requires: 
    [
      "Ext.form.field.Hidden",
      "Ext.form.field.Text",
      "Ext.form.field.Checkbox",
      "Ext.form.field.TextArea",
      //"Ext.form.field.ComboBox",
      "Ext.form.field.Date"
   ],
   uses:
    [
      //'DarkOwl.User_Manager.Windows.Setup.cCreateDB',
   ],
   labelWidth : 60,
   buttonAlign:'right',
   frame : true,
   timeout:1000,
   bodyStyle : 'padding:5px 5px 0',
   autoWidth:true,
   autoHeight:true,
   standardSubmit : false,
   defaultType : 'textfield',
   
   
   initComponent: function () 
    {
      var obj_This = this;
      
      this.buttons = 
      [
         {
              text: 'Cancel',
              autoWidth:true,
              disabled:false,
              handler: function()
              {
               obj_This.ownerCt.close();
               }
          },
      {
              text: 'Submit',
              disabled:false,
              autoWidth:true,
              formBind:true,
              scope:this,
              handler: function()
              {
               obj_This.getForm().submit(
                     {
                        url:obj_config.C_STR_EXTERNAL_PATH+'/HarvestRequest/submitDeactivation.php', 
                        waitMsg:'Submitting Your Deactivation Request',
                        success: this.submit_Success,
                        failure: this.submit_Fail,
                        scope: obj_This
                     });
               }
          }
      ];
      
      this.callParent();
      
      this.m_obj_Form_HarvestID = Ext.create("Ext.form.field.Hidden",
            {
               name : "HarvestID",
                    disabled:  false,
                    readOnly: true,
                    allowBlank : false
            });
      
      this.add(this.m_obj_Form_HarvestID);
      
      this.m_obj_Form_UserName = Ext.create("Ext.form.field.Text",
            {
               fieldLabel  : "User",
               name : "User Name",
               inputType:"textfield",
               anchor:"100%",
                    disabled:  false,
                    readOnly: true,
                    allowBlank : false, 
                    value: obj_config.user.userName //"<?php print($obj_UserValidation->get_UserName());?>"
            });
      
      this.add(this.m_obj_Form_UserName);
      
      this.add(Ext.create("Ext.form.field.TextArea",
            {
               fieldLabel  : "Reason",
               name : "Reason",
               anchor:"100%",
                    allowBlank : false              
            }));
      this.add(Ext.create("Ext.form.field.Checkbox",
            {
               fieldLabel  : "Not Valid",
               name  : "No Longer Valid"
            }));
      
      this.add(Ext.create("Ext.form.field.Date",
            {
               fieldLabel  : "Deactivation Date",
               name : "Deactivation Date",
                    allowBlank : false              
            }));
      
      this.add(Ext.create("Ext.panel.Panel",
         {
            frame:true,
            html:"<p>All deactivation requests can take up to five working days to take effect.</p>"+
            "<p>If this is an emergency deactivation request due to mission critical needs call the following individuals for rapid untasking.</p>"+
            "<center>Harvest Manager - 555-5555<br/>"+
            "Project Manager - 555-5555</center>"
         }));
      

    } ,
    
    set_RequestID:function(str_ID)
    {
      var obj_This = this;
      this.m_obj_Form_HarvestID.setValue(str_ID);

    },
    
    submit_Success:function (str_Function,mix_Arg)
   {
      m_obj_AmpleHarvest_ViewPort.down('ampleharvest-objects-harvestrequest-view-harvestrequest').refreshData();
      this.ownerCt.close();
      
      Ext.MessageBox.alert(
               "Success",
               "Your Deactivation Request has been sent.", 
               close);
   },
   

   submit_Fail:function (str_Function,mix_Arg)
   {
      Ext.MessageBox.alert(
               "Error",
               mix_Arg.result.errors.msg, 
               close);
   }
});